<template>
	<view class="ports">
		<view class="ports-title">选择您要进入的后台</view>
		<view class="ports-string"></view>
		<view class="ports-list" v-for="(item,index) in listData" :key='index' @tap="pottsBtn(item)" v-if="item.identity">
			<view class="img"><image :src="`${basic}${shopInfo.defaultHead}`" mode=""></image></view>
			<view class="txt">
				<view class="txt-title">{{item.title}}</view>
				<view class="txt-num">{{shopInfo.phone}}</view>
			</view>
			<view class="right" v-if="item.show">当前使用</view>
		</view>
	</view>
</template>

<script>
import CONSTS from '@/src/consts';
	export default {
		data(){
			return{
				basic:CONSTS.BASE_URL+'/basic',
				listData:[
					{title:'888个人店主',url:'/personal/src/pages/home/index',show:true,identity:false},
					{title:'生活圈商家版',url:'/src/pages/index/index',show:false,identity:false},
					{title:'百货商家版',url:'/src/pages/index/index',show:false,identity:false},
					{title:'8888合伙人',url:'/src/pages/index/index',show:false,identity:false},
					{title:'进销存',url:'/src/pages/index/index',show:false,identity:false}
				],
				shopInfo:[],
				userInfo:[],
			}
		},
		onLoad() {
			let _this= this
			uni.getStorage({
			    key: 'shopInfo',
			    success: function (res) {
			        console.log(res.data);
					_this.shopInfo = res.data
			    }
			});
			uni.getStorage({
			    key: 'userInfo',
			    success: function (res) {
					_this.userInfo = res.data
					_this.listData[0].identity = true
					if(res.data.isShopkeeper === 1){
						_this.listData[0].identity = true
					}
					if(res.data.accounttype === 1){
						_this.listData[1].identity = true
					}
			    }
			});
		},
		methods:{
			pottsBtn(item){
				
				if(item.title === '生活圈商家版'){
					this.$utils.common.switchTab(item.url)
				}else{
					uni.redirectTo({
						url:item.url
					})
				}
				
			}
		}
	}
</script>

<style lang="scss">
	.ports{
		width:100%;
		height:100vh;
		background:rgba(249,250,255,1);
		opacity:1;
		padding: 180rpx 32rpx 0 32rpx;
		&-title{
			width:100%;
			font-size:40rpx;
			font-family:PingFang SC;
			font-weight:bold;
			color:rgba(80,80,80,1);
			opacity:1;
			text-align: center;
			
		}
		&-string{
			width:206rpx;
			height:0px;
			border:2rpx solid rgba(230,230,230,1);
			opacity:1;
			margin:0 auto;
			margin-top: 44rpx;
			margin-bottom: 110rpx;
		}
		&-list{
			width:686rpx;
			height:140rpx;
			background:rgba(255,255,255,1);
			box-shadow:0rpx 6rpx 12rpx rgba(0,0,0,0.16);
			opacity:1;
			border-radius:10rpx;
			display: flex;
			align-items: center;
			padding: 20rpx;
			margin-bottom: 30rpx;
			.img{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				overflow: hidden;
				image{
					width: 100%;
					height: 100%;
				}
			}
			.txt{
				margin-left: 30rpx;
				&-title{
					font-size:28rpx;
					font-family:PingFang SC;
					font-weight:bold;
					color:rgba(80,80,80,1);
					opacity:1;
					margin-bottom: 6rpx;
				}
				&-num{
					font-size:24rpx;
					font-family:PingFang SC;
					font-weight:400;
					color:rgba(80,80,80,1);
					opacity:1;
				}
			}
			.right{
				width:124rpx;
				height:40rpx;
				background-color:#bbe2ff;
				opacity:0.2;
				border-radius:4rpx;
				font-size:24rpx;
				font-family:PingFang SC;
				font-weight:bold;
				color:rgba(0,144,250,1);
				opacity:1;
				text-align: center;
				line-height: 40rpx;
				margin-left: auto;
			}
		}
	}
</style>
